package demo;

import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.common.message.Message;

import java.nio.charset.StandardCharsets;

/**
 * 单向消息
 * 生产者不返回发送结果
 */
public class OneWayProducerMessage {
    public static void main(String[] args) throws Exception {
        DefaultMQProducer producer = new DefaultMQProducer("OneWayGroup");
        producer.setNamesrvAddr("192.168.86.104:10001");
        producer.start();
        for(int i=0;i<100;i++) {
            Message msg = new Message("demo_topic","tag1",
                    ("OneWay_HelloWorld"+i).getBytes(StandardCharsets.UTF_8));
            producer.sendOneway(msg);
        }
        producer.shutdown();
    }
}
